<template>
    <div>
        <div class="order-body">
            <window-title title="修改密码"></window-title>
            <el-form size="mini">
                <el-form-item label="原密码">
                    <el-input placeholder="请输入原密码" v-model="old_pwd"></el-input>
                </el-form-item>
                <el-form-item label="新密码">
                    <el-input placeholder="请输入新密码" v-model="password" type="password"></el-input>
                </el-form-item>
                <el-form-item label="重复密码">
                    <el-input placeholder="请输入重复密码" v-model="re_password" type="password"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button class="com-btn" @click="submitDo()">确定修改</el-button>
                </el-form-item>
            </el-form>
        </div>
    </div>
</template>

<script>
import windowTitle from '../../components/title/title.vue';

export default {
    components: { windowTitle },
    data() {
        return {
            old_pwd: '',
            password: '',
            re_password: '',
        }
    },
    methods: {
        submitDo() {
            if (!this.old_pwd) return this.toast(0, '请输入原密码');
            if (!this.password) return this.toast(0, '请输入新密码');
            if (this.password != this.re_password) return this.toast(0, '重复密码错误');
            this.ajaxs('user/setPwd', {
                data: {
                    old_pwd: this.old_pwd,
                    password: this.password,
                },
                success: (res) => {
                    this.toast(res.code, res.msg);
                    if (res.code) {
                        this.$router.push({
                            path: '/index/index/index'
                        })
                    }
                }
            })
        },
    }
}
</script>

<style scoped>
@import url('../../assets/css/order/list.css');
</style>
